<template>
<div>

  <van-field label="用户名" v-model="form.name"/>
  <van-field label="密码" v-model="form.password"/>
  <select name="" id="" v-model="form.role_id">
    <option :value="i.id" v-for="i in rlost">{{i.name}}</option>

  </select>
  <van-button @click="add_user">添加</van-button>
</div>
</template>

<script>
export default {
  name: "add_admin",
  data(){
    return{
      rlost:[],
      form:{}
    }
  },
  methods:{
    get_rlost(){
      this.$axios.get('admin/rolesM').then(res=>{
        this.rlost  = res.data.list
      })
    },
    add_user(){
      this.$axios.post('admin/userM',this.form).then(res=>{
        if(res.data.code==200){
          alert('ok')
        }else {
          alert('no')
        }
      })
    }
  },
  mounted() {
    this.get_rlost()
  }
}
</script>

<style scoped>

</style>
